1
'************************************** Module Header **************************************'
2 ' Module Name: ServiceInstaller.vb
3 ' Project: VBWin7TriggerStartService
4 ' Copyright (c) Microsoft Corporation.
6 ' In ServiceInstaller, we configure the service to start when a generic USB disk becomes
7 ' available. It also shows how to trigger-start when the first IP address becomes available,
8 ' and trigger-stop when the last IP address becomes unavailable.
10 ' This source is subject to the Microsoft Public License.
11 ' See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
12 ' All other rights reserved.
14 ' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
15 ' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
16 ' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
17 '*******************************************************************************************'
19 #Region
"Imports directives"
21 Imports System
.ComponentModel
22 Imports System
.Configuration
.Install
23 Imports System
.ServiceProcess
24 Imports System
.Runtime
.InteropServices
29 Public Class ServiceInstaller
33 'This call is required by the Component Designer.
38 Private Sub ServiceInstaller1_AfterInstall(ByVal sender
As System
.Object, ByVal e
As System
.Configuration
.Install
.InstallEventArgs
) Handles ServiceInstaller1
.AfterInstall
40 ' If Service Trigger Start is supported on the current system, configure the service
42 If (ServiceTriggerStart
.IsSupported
) Then
43 Console
.WriteLine("Configuring trigger-start service...")
45 ' Set the service to trigger-start when a generic USB disk becomes available.
46 ServiceTriggerStart
.SetServiceTriggerStartOnUSBArrival( _
47 ServiceInstaller1
.ServiceName
)
51 ' Set the service to trigger-start when the first IP address becomes
52 ' available, and trigger-stop when the last IP address becomes unavailable.
53 'ServiceTriggerStart.SetServiceTriggerStartOnIPAddressArrival( _
54 'ServiceInstaller1.ServiceName)
57 Console
.WriteLine("Service Trigger Start configuration failed with " & ex
.Message
)
60 Console
.WriteLine("The current system does not support trigger-start service.")